/**
 * 内联样式的ref回调 在更改state时,执行两次
 */
class Person extends React.Component{
  state={isHot:true};
  myRef=React.createRef();
  myRef2=React.createRef();
	showData=()=>{
		// const {input1}=this.refs;
		alert(this.myRef.current.value)
	}
	showData2=()=>{
		console.log(this)
		// const {input2}=this.refs;
		alert(this.myRef2.current.value)
	}
	changeWeather=()=>{
		this.setState({
			isHot:!this.state.isHot
		});
	}
	saveInput=(c)=>{
		this.input1=c;
		console.log('@',c)
	}
	render(){
		return (
			<div>
				<h2>今天天气很{this.state.isHot ? "炎热" :"凉爽"}</h2><br/>
				<input type="text" ref={this.myRef} placeholder="请输入"/><br/>
				<button onClick={this.showData}>点击提示数据</button><br/>
				<input type="text" ref={this.myRef2}  onBlur={this.showData2} placeholder="失去焦点提示信息"/><br/>
				<button onClick={this.changeWeather}>点我更新天气</button>
			</div>
		);
	}
}
ReactDOM.render(<Person/> ,document.getElementById("test"));
